﻿<%@ Page Language="C#" MasterPageFile="~/Admin/Admin.Master" AutoEventWireup="true" CodeBehind="LienHe.aspx.cs" Inherits="NEWS.Admin.LienHe" %>
<%@ Register assembly="msgBox" namespace="BunnyBear" tagprefix="cc1" %>
<asp:Content ID="content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
 
    <script type="text/javascript">

function confirmAction() {
    if(confirm('Bạn có chắc chắn muốn xóa???')) {
        // you clicked the OK button.
        // you can allow the form to post the data.
        return true;
    }
    else {
      
       
        // you clicked the Cancel button.
        // you can disallow the form submission.
        return false;
    }
}
 </script>
 <script type="text/javascript">
    function SelectAll(CheckBox)
    {
        TotalChkBx = parseInt('<%= this.GridView1.Rows.Count %>');    
        var TargetBaseControl = document.getElementById('<%= this.GridView1.ClientID %>');
        var TargetChildControl = "chkSelect";   
        var Inputs = TargetBaseControl.getElementsByTagName("input");
        for(var iCount = 0; iCount < Inputs.length; ++iCount)
        {                
            if(Inputs[iCount].type == 'checkbox' && Inputs[iCount].id.indexOf(TargetChildControl,0) >= 0)
                Inputs[iCount].checked = CheckBox.checked;   
        }

    }
    
    function SelectDeSelectHeader(CheckBox)
    {        
        TotalChkBx = parseInt('<%= this.GridView1.Rows.Count %>');    
        var TargetBaseControl = document.getElementById('<%= this.GridView1.ClientID %>');
        var TargetChildControl = "chkSelect";   
        var TargetHeaderControl = "chkSelectAll";   
        var Inputs = TargetBaseControl.getElementsByTagName("input");
        var flag = false;
        var HeaderCheckBox;
        for(var iCount = 0; iCount < Inputs.length ; ++iCount)
        {    
            if(Inputs[iCount].type == 'checkbox' && Inputs[iCount].id.indexOf(TargetHeaderControl,0) >= 0)            
                HeaderCheckBox = Inputs[iCount];            
            if(Inputs[iCount] != CheckBox && Inputs[iCount].type == 'checkbox' && Inputs[iCount].id.indexOf(TargetChildControl,0) >= 0 && Inputs[iCount].id.indexOf(TargetHeaderControl,0) == -1)
            {            
                if(CheckBox.checked)
                {                    
                    if(!Inputs[iCount].checked)                    
                    {                    
                        flag = false;
                        HeaderCheckBox.checked = false;                       
                        return;
                    }
                    else
                        flag = true;                    
                }
                else if(!CheckBox.checked)                
                    HeaderCheckBox.checked = false;                                                       
            }            
        }                      
        if(flag)        
            HeaderCheckBox.checked = CheckBox.checked        
    }
</script>

<asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" >
     <ContentTemplate>
           <asp:Panel ID="PanelDasboard" runat="server"  Visible="true">
            <div class="dashboard">
                <h2 class="ico_mug">
                    <asp:Label ID="lblcontact" runat="server" Text="Danh sách hỗ trợ trực tuyến"></asp:Label>
                </h2>

                <div style="width:100%; margin-bottom:10px;">
                    <p style="margin-right:10px;float:left;">
                        <asp:DropDownList ID="dlhotro" runat="server" Visible="false" AutoPostBack="true"
                            OnSelectedIndexChanged="dlhotro_SelectedIndexChanged">
                            <asp:ListItem Selected="True">Hiển Thị Tất Cả</asp:ListItem>
                            <asp:ListItem>Theo Yahoo</asp:ListItem>
                            <asp:ListItem>Theo Skyper</asp:ListItem>
                        </asp:DropDownList>
                    </p>
                    <p style="margin-right:10px;float:left;"><asp:LinkButton ID="btnthem" 
                            runat="server" Font-Bold="True" ForeColor="Blue" Visible="false" 
                            onclick="btnthem_Click">Thêm</asp:LinkButton></p>
                    <p><asp:LinkButton ID="btnxoa" runat="server" Font-Bold="True" ForeColor="Blue" 
                            Visible="false" onclick="btnxoa_Click" OnClientClick="javascript:return confirmAction();">Xóa 
                        Lựa Chọn</asp:LinkButton></p>
                </div>

                <div>
                    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
                        CellPadding="4" DataKeyNames="ContactID"
                        Width="100%" 
                        onselectedindexchanged="GridView1_SelectedIndexChanged" AllowPaging="True" 
                        
                        ForeColor="#333333" GridLines="None" 
                        onrowdatabound="GridView1_RowDataBound" 
                        onrowcommand="GridView1_RowCommand" >
                        <FooterStyle BackColor="#507CD1" ForeColor="White" Font-Bold="True" />
                        <RowStyle BackColor="#EFF3FB" />
                        <Columns>
                            <asp:CommandField ButtonType="Image" SelectImageUrl="~/Admin/img/edit.png" 
                                ShowSelectButton="True" >
                                <HeaderStyle HorizontalAlign="Center" />
                                <ItemStyle Width="50px" HorizontalAlign="Center" />
                            </asp:CommandField>
                            <asp:TemplateField>
                                <ItemTemplate>
                                    <asp:LinkButton ID="lbtnxem" runat="server" CommandName="Xem" 
                                        CausesValidation="False">Xem</asp:LinkButton>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField>
                                <ItemTemplate>
                                    <asp:CheckBox ID="chkSelect" runat="server" />
                                </ItemTemplate>
                                <HeaderTemplate>
                                 <asp:CheckBox ID="chkSelectAll" runat="server" onclick="SelectAll(this);" />                                
                                </HeaderTemplate>
                                <HeaderStyle HorizontalAlign="Center" />
                                <ItemStyle Width="50px" HorizontalAlign="Center" />
                            </asp:TemplateField>
                            <asp:BoundField DataField="ContactID" HeaderText="ID" ReadOnly="True" 
                                SortExpression="ContactID" InsertVisible="False" >
                                <HeaderStyle HorizontalAlign="Center" />
                                <ItemStyle Width="150px" HorizontalAlign="Center" />
                            </asp:BoundField>
                            <asp:BoundField DataField="Name" HeaderText="Tên Hổ Trợ" 
                                SortExpression="Name" >
                                <HeaderStyle HorizontalAlign="Left" />
                                <ItemStyle HorizontalAlign="Left" />
                            </asp:BoundField>
                            <asp:BoundField DataField="IsYahoo" HeaderText="Yahoo" 
                                SortExpression="IsYahoo" >
                                <HeaderStyle HorizontalAlign="Left" />
                                <ItemStyle HorizontalAlign="Left" />
                            </asp:BoundField>
                            <asp:BoundField DataField="IsSkyper" HeaderText="Skyper" 
                                SortExpression="IsSkyper" >
                                <HeaderStyle HorizontalAlign="Left" />
                                <ItemStyle HorizontalAlign="Left" />
                            </asp:BoundField>
                            <asp:BoundField DataField="Title" HeaderText="Tiêu Đề Liên Hệ" 
                                SortExpression="Title" DataFormatString="{0:dd/mm/yyyy}" >
                                <HeaderStyle HorizontalAlign="Left" />
                                <ItemStyle HorizontalAlign="Left" />
                            </asp:BoundField>
                            <asp:TemplateField HeaderText="Đã Đọc">
                                <ItemTemplate>
                                    <asp:CheckBox ID="cbdadoc" runat="server" Checked='<%# Eval("IsCheck") %>' Enabled="false"/>
                                </ItemTemplate>
                                <HeaderStyle HorizontalAlign="Center" />
                                <ItemStyle HorizontalAlign="Center" />
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Kích hoạt">
                                <ItemTemplate>
                                    <asp:CheckBox ID="CheckBox1" runat="server" Checked='<%# Eval("IsActive") %>' 
                                        Enabled="False" />
                                </ItemTemplate>
                                <HeaderStyle HorizontalAlign="Center" />
                                <ItemStyle HorizontalAlign="Center" />
                            </asp:TemplateField>
                        </Columns>
                        <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
                        <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
                        <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                        <EditRowStyle BackColor="#2461BF" />
                        <AlternatingRowStyle BackColor="White" />
                    </asp:GridView>
                    <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" 
                        SelectMethod="GetContactBOList" 
                        TypeName="HousingInfo.Library.ContactBOList">
                    </asp:ObjectDataSource>
                    <asp:Label ID="messagedelete" runat="server" Font-Bold="True" Font-Size="Small" 
                        ForeColor="Red"></asp:Label>
                    <br />
                </div>
            </div>
       </asp:Panel>
    <asp:Panel ID="PanelActions" runat="server"  Visible="false">
    <div class="dashboard">
        <h2 class="ico_mug">
            <asp:Label ID="lbHeaderActions" runat="server" Text="Chỉnh Sửa Chi Tiết"></asp:Label>
        </h2>
       
       
        <div>
            <table style="width: 100%">
                <tr>
                    <td style="width: 132px">
                        </td>
                    <td style="width: 19px">
                        </td>
                    <td>
                        <asp:Label ID="message" runat="server" Font-Bold="True" Font-Size="Small" 
                            ForeColor="Red"></asp:Label>
                    </td>
                </tr>
                <tr>
                    <td style="width: 132px; text-align: right;">

                        <asp:Label ID="lblcontactid" runat="server" Text="ID :"></asp:Label>
                    </td>
                    <td style="width: 19px">
                        </td>
                    <td>
                        <asp:TextBox ID="txtcontactid" runat="server" ReadOnly="True" Width="172px" 
                            Enabled="False"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td style="width: 132px; text-align: right;">
                        <asp:Label ID="Label6" runat="server" Text="Tên Người Hổ Trợ :"></asp:Label>
                    </td>
                    <td style="width: 19px">
                        &nbsp;</td>
                    <td>
                        <asp:TextBox ID="txtname" runat="server" Width="172px" MaxLength="100"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator7" runat="server" 
                            ControlToValidate="txtname" ErrorMessage="?"></asp:RequiredFieldValidator>
                        <asp:RegularExpressionValidator ID="RegularExpressionValidator6" runat="server" 
                            ControlToValidate="txtname" ErrorMessage="Độ dài tối thiểu &gt; 2 và tối đa là 100" 
                            ValidationExpression="^([\S\s]{3,100})$"></asp:RegularExpressionValidator>
                    </td>
                </tr>      
                <tr>
                    <td style="width: 132px; text-align: right;">
                        <asp:Label ID="lblyahoo" runat="server" Text="Nick Yahoo :"></asp:Label>
                    </td>
                    <td style="width: 19px">
                        &nbsp;</td>
                    <td>
                        <asp:TextBox ID="txtnickyahoo" runat="server" Width="172px" MaxLength="50"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" 
                            ControlToValidate="txtnickyahoo" ErrorMessage="?"></asp:RequiredFieldValidator>
                        <asp:RegularExpressionValidator ID="RegularExpressionValidator3" runat="server" 
                            ControlToValidate="txtnickyahoo" ErrorMessage="Độ dài từ 3-50 ký tự" 
                            ValidationExpression="^([\S\s]{3,50})$" Display="Dynamic"></asp:RegularExpressionValidator>
                        <asp:RegularExpressionValidator ID="RegularExpressionValidator14" 
                            runat="server" ErrorMessage=" Nick Yahoo không hợp lệ" ValidationExpression="\w+([_.]\w+)*" ControlToValidate="txtnickyahoo"></asp:RegularExpressionValidator>
                    </td>
                </tr>
                      
                <tr>
                    <td style="width: 132px; text-align: right;">
                        <asp:Label ID="Lblskyper" runat="server" Text="Nick Skyper :"></asp:Label>
                    </td>
                    <td style="width: 19px">
                        &nbsp;</td>
                    <td>
                        <asp:TextBox ID="txtnickskyer" runat="server" Width="172px" MaxLength="50"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
                            ControlToValidate="txtnickskyer" ErrorMessage="?"></asp:RequiredFieldValidator>
                        <asp:RegularExpressionValidator ID="RegularExpressionValidator7" runat="server" 
                            ControlToValidate="txtnickskyer" ErrorMessage="Độ dài từ 3-50 ký tự" 
                            ValidationExpression="^([\S\s]{3,50})$" Display="Dynamic"></asp:RegularExpressionValidator>
                            <asp:RegularExpressionValidator ID="RegularExpressionValidator15" 
                            runat="server" ErrorMessage=" Nick Skyper không hợp lệ" ValidationExpression="\w+([_.]\w+)*" ControlToValidate="txtnickskyer"></asp:RegularExpressionValidator>
                    </td>
                </tr>
                <tr>
                    <td style="width: 132px; text-align: right;">
                        <asp:Label ID="lblcreatedate" runat="server" Text="Ngày Tạo :"></asp:Label>
                    </td>
                    <td style="width: 19px">
                        &nbsp;</td>
                    <td>
                        <asp:TextBox ID="txtcreatdate" runat="server" Enabled="False" ReadOnly="True" 
                            Text='<%# Eval("CreadedDate", "{0:dd/MM/yyyy}") %>' Width="172px"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td style="width: 132px; text-align: right;">
                        <asp:Label ID="Label10" runat="server" Text="Kích hoạt :"></asp:Label>
                    </td
                    <td style="width: 19px">
                        &nbsp;</td>
                    <td>
                        <asp:CheckBox ID="isActive" runat="server" />
                    </td>
                </tr>
                <tr>
                    <td style="width: 132px; height: 45px;">
                    </td>
                    <td style="width: 19px; height: 45px;">
                    </td>
                    <td style="height: 45px">
                        <asp:Button ID="btnUpdate" runat="server" onclick="btnUpdate_Click" 
                            Text="Cập nhật" />
                        <asp:Button ID="btnAdd" runat="server" onclick="btnAdd_Click" Text="Thêm" />
                        <asp:Button ID="btndong" runat="server" CausesValidation="False" 
                            onclick="btndong_Click" Text="Hủy bỏ" />
                    </td>
                </tr>
            </table>
        </div>
    </div>
     </asp:Panel>    
     <asp:Panel ID="pnlienhe" runat="server" Visible="false">
     <div class="dashboard">
        <h2 class="ico_mug">
            <asp:Label ID="Label1" runat="server" Text="Thông tin liên hệ"></asp:Label>
        </h2>
       
        <div>
            <table style="width: 100%">
                <tr>
                    <td style="width: 132px; text-align: right;">
                        <asp:Label ID="lblemail" runat="server" Text="Email :"></asp:Label>
                    </td>
                    <td style="width: 19px">
                        </td>
                    <td>
                        <asp:Label Width="90%" ID="txtemail" runat="server" Text="email"></asp:Label>
                    </td>
                </tr>
                <tr>
                    <td style="width: 132px; text-align: right;">
                        <asp:Label ID="lbltitle" runat="server" Text="Tiêu đề liên hệ :"></asp:Label>
                    </td>
                    <td style="width: 19px">
                        </td>
                    <td>
                        <asp:Label Width="90%" ID="txttitle" runat="server" Text="tieu de"></asp:Label>
                    </td>
                </tr>
                <tr>
                    <td style="width: 132px; text-align: right;">
                        <asp:Label ID="lblcontactcontent" runat="server" Text="Nội dung liên hệ :"></asp:Label>
                    </td>
                    <td style="width: 19px">
                    </td>
                    <td>
                        <asp:Label Width="90%" ID="txtcontactcontent" runat="server" Text="noi  dung"></asp:Label>
                    </td>
                </tr>
                <tr>
                    <td style="width: 132px; text-align: right;">
                        <asp:Label ID="lblngaygui" runat="server" Text="Ngày Gửi :"></asp:Label>
                    </td>
                    <td style="width: 19px">
                        &nbsp;</td>
                    <td>
                        <asp:Label ID="txtngaygui" runat="server" Text="Ngay Gui"></asp:Label>
                    </td>
                </tr>
                <asp:Panel ID="Panel1" runat="server" Visible="false">  
                    <tr>
                        <td style="width: 132px; text-align: right;">
                            <asp:Label ID="lblfrom" runat="server" Text="Gửi Từ Email :"></asp:Label>
                        </td>
                        <td style="width: 19px">
                        </td>
                        <td>
                            <asp:TextBox ID="txtfrom" Width="90%" runat="server"></asp:TextBox> 
                            <br />
                            <asp:RegularExpressionValidator ControlToValidate="txtfrom" ID="RegularExpressionValidator16" 
                                runat="server" ErrorMessage="Email Không Hợp Lệ" 
                                ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator>
                            <asp:RequiredFieldValidator ControlToValidate="txtfrom" ID="RequiredFieldValidator3" runat="server" ErrorMessage="Yêu Cầu Nhập Email"></asp:RequiredFieldValidator>                           
                        </td>
                    </tr>    
                    <tr>
                        <td style="width: 132px; text-align: right;">
                            <asp:Label ID="lbltitlefrom" runat="server" Text="Tiêu Đề Email :"></asp:Label>
                        </td>
                        <td style="width: 19px">
                        </td>
                        <td>
                            <asp:RequiredFieldValidator ControlToValidate="txttitlefrom" ID="RequiredFieldValidator4" runat="server" ErrorMessage="Tiêu Đề Email Không Được Rỗng"></asp:RequiredFieldValidator>
                            <asp:TextBox ID="txttitlefrom" Width="90%" runat="server"></asp:TextBox>                            
                        </td>
                    </tr>    
                    <tr>
                        <td style="width: 132px; text-align: right;">
                            <asp:Label ID="lbltraloi" runat="server" Text="Nội Dung Trả lời :"></asp:Label>
                        </td>
                        <td style="width: 19px">
                        </td>
                        <td>
                            <asp:TextBox ID="txttraloi" Height="150px" Width="90%" runat="server"
                                TextMode="MultiLine"></asp:TextBox>
                                <br /><asp:RequiredFieldValidator ID="RequiredFieldValidator2"
                                    runat="server" ErrorMessage="       Nội dung không được trống" 
                                ControlToValidate="txttraloi"></asp:RequiredFieldValidator>
                        </td>
                    </tr>
                </asp:Panel>
                
                
                                               
                <tr>
                    <td style="width: 132px; height: 45px;">
                    </td>
                    <td style="width: 19px; height: 45px;">
                    </td>
                    <td style="height: 45px">
                        <asp:Button ID="btnsend" runat="server" Visible="false" onclick="btnsend_Click" 
                            Text="Gửi" />
                        <asp:Button ID="btnreply" runat="server" Text="Trả lời Email" 
                            onclick="btnreply_Click" CausesValidation="False" />
                        <asp:Button ID="btndonglienhe" runat="server" CausesValidation="False" 
                            onclick="btndonglienhe_Click" Text="Đóng" />
                     </td>
                </tr>
                
                
            </table>
        </div>
    </div>
     </asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Content>
 

